﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DiscoveryLogic.Common.Utilities;

namespace DiscoveryLogic.Analytics.DataObjects.Measures
{
    public class VerticeMeasureRange
    {
        private EntityType _EntityType;
        /// <summary></summary>
        public Common.Utilities.EntityType EntityType
        {
            get
            {
                return this._EntityType;
            }
            set
            {
                this._EntityType = value;
            }
        }

        private Range<int> _DegreeRange;
        /// <summary></summary>
        public Range<int> DegreeRange
        {
            get
            {
                return this._DegreeRange;
            }
            set
            {
                this._DegreeRange = value;
            }
        }

        private Range<int> _InDegreeRange;
        /// <summary></summary>
        public Range<int> InDegreeRange
        {
            get
            {
                return this._InDegreeRange;
            }
            set
            {
                this._InDegreeRange = value;
            }
        }

        private Range<int> _OutDegreeRange;
        /// <summary></summary>
        public Range<int> OutDegreeRange
        {
            get
            {
                return this._OutDegreeRange;
            }
            set
            {
                this._OutDegreeRange = value;
            }
        }

        private Range<double> _BetweenCentralityRange;
        /// <summary></summary>
        public Range<double> BetweenCentralityRange
        {
            get
            {
                return this._BetweenCentralityRange;
            }
            set
            {
                this._BetweenCentralityRange = value;
            }
        }

        private Range<double> _CloseCentralityRange;
        /// <summary></summary>
        public Range<double> CloseCentralityRange
        {
            get
            {
                return this._CloseCentralityRange;
            }
            set
            {
                this._CloseCentralityRange = value;
            }
        }

        private Range<int> _FlowRange;
        /// <summary></summary>
        public Range<int> FlowRange
        {
            get
            {
                return this._FlowRange;
            }
            set
            {
                this._FlowRange = value;
            }
        }

        public static double LinearScale(double minOut, double maxOut, Range<int> rangeIn, int valueIn)
        {
            if (rangeIn.ToValue > rangeIn.FromValue)
            {
                double scale = (double)(valueIn - rangeIn.FromValue)/(rangeIn.ToValue - rangeIn.FromValue);
                return minOut + scale*(maxOut - minOut);
            }
            else
                return minOut;
        }

        public static double LinearScale(double minOut, double maxOut, Range<double> rangeIn, double valueIn)
        {
            if (rangeIn.ToValue > rangeIn.FromValue)
            {
                double scale = (valueIn - rangeIn.FromValue) / (rangeIn.ToValue - rangeIn.FromValue);
                return minOut + scale * (maxOut - minOut);
            }
            else
                return minOut;
        }
    }
}
